#include <bits/stdc++.h>
using namespace std;
vector<int> a;

int main() {
  // srand(time(0));
  for (int i = 0; i < 20; i++) {
    a.push_back(rand() % 100);
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < 20; i++) {
    cout << a[i] << " ";
  }
  //>=5的第一个位置
  int pos1 = lower_bound(a.begin(), a.end(), 5) - a.begin();
  cout << pos1 << endl;

  //   >5的第一个位置
  int pos2 = upper_bound(a.begin(), a.end(), 5) - a.begin();
  cout << pos2 << endl;

  // 5 的个数
  cout << pos2 - pos1; //

  int l = 0, r = 20;
  int ans = 0;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (a[mid] >= 5) {
      r = mid - 1;
      ans = mid;
    } else {
      l = mid + 1;
    }
  }
  cout << ans<< endl;
  return 0;
}